package com.print2;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

@Service
public class Printer {
    @Value("惠普HP505")
    private String brand;
    @Value("1299")
    private int price;

    @Autowired
//    @Qualifier("b5")
    @Qualifier("a4")
    private Paper paper;
    @Autowired
    @Qualifier("ColorInk")
    private Ink ink;

    public Printer() {
        System.out.println(this.brand+"(￥"+this.price+")"+"打印机已构造~");
        System.out.println("Printer构造时间："+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date()));
    }


    public void print(String str){
        System.out.println(this.brand+"(￥"+this.price+")"+"打印机已准备好~");
        System.out.println("使用"+ink.getColor()+"打印……");
        paper.print(str);
    }
}
